package org.noote.libs.sogle.helper;

import org.noote.libs.sogle.Mesh;

public class Mesh_Box extends Mesh {
	
	public Mesh_Box(float width, float height, float depth) {
		width /= 2;
		height /= 2;
		depth /= 2;

		float vertices[] = { -width, -height, -depth, width, -height, -depth,
				width, height, -depth, -width, height, -depth, -width, -height,
				depth, width, -height, depth, width, height, depth, -width,
				height, depth };

		short indices[] = { 0, 5, 4,
				0, 1, 5,
				1, 6, 5,
				1, 2, 6,
				2, 7, 6,
				2, 3, 7,
				3, 4, 7,
				3, 0, 4,
				4, 6, 7,
				4, 5, 6,
				3, 1, 0,
				3, 2, 1 };

		setIndices(indices);
		setVertices(vertices);
		generateNormales();
	}	 

	public Mesh_Box(float width, float height, float depth, boolean b) {
		width /= 2;
		height /= 2;
		depth /= 2;

		float vert[] = {-width, -height, -depth, // 0
				width, -height, -depth, // 1
				width, height, -depth, // 2
				-width, height, -depth, // 3
				-width, -height, depth, // 4
				width, -height, depth, // 5
				width, height, depth, // 6
				-width, height, depth // 7
		};

		short tri[] = {0, 5, 4,
				0, 1, 5,
				1, 6, 5,
				1, 2, 6,
				2, 7, 6,
				2, 3, 7,
				3, 4, 7,
				3, 0, 4,
				4, 6, 7,
				4, 5, 6,
				3, 1, 0,
				3, 2, 1};
		
		short indices[] = new short[tri.length];
		float vertices[] = new float[tri.length * 3];

		for (int i = 0; i < indices.length; i++) {
			indices[i] = (short) i;
		}

		for (int v = 0; v < tri.length; v++) {
			vertices[v*3  ] = vert[tri[v]*3  ];
			vertices[v*3+1] = vert[tri[v]*3+1];
			vertices[v*3+2] = vert[tri[v]*3+2];
		}

		setIndices(indices);
		setVertices(vertices);
		generateNormales();
	}
}
